package com.ethan.guava;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import javafx.util.Pair;

import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
 * @author ethan
 * create 2018-04-03 下午8:47
 * desc
 **/
public class StatusMap {
    public static void main(String[] args) {
        //ImmutableMap<String,String> map = ImmutableMap.of("aaa","111","bbb","222","ccc","333");

//        ImmutableList<Pair<String,String>>
//        StatusMap statusMap = new StatusMap();
//        statusMap.addStatusMapping("50","1");
//        statusMap.addStatusMapping("10","12");
//        statusMap.addStatusMapping("13","12");
//        statusMap.addStatusMapping("13","10");
//
//        System.out.println(statusMap.hasStatusMapping("29","1"));
//        System.out.println(statusMap.hasStatusMapping("13","12"));


        //Set<Pair<String,String>> sets= Sets.newConcurrentHashSet();

//        Pair<String,String> query = new Pair<>("12","23");
//        System.out.println(sets.contains(query));

        Map<String,String> map = Maps.newHashMap();



        addStatusMapping("30","10");
        addStatusMapping("12","34");
        addStatusMapping("12","20");

        boolean results = hasStatusMapping("1","20");

        String str ="";
    }

    public static boolean hasStatusMapping(String fromStatus,String toStatus){
        return mappings.contains(new Pair<>(fromStatus, toStatus));
    }

    public static void addStatusMapping(String fromStatus,String toStatus){
        mappings.add(new Pair<>(fromStatus,toStatus));
    }

    public static void removeStatusMapping(String fromStatus,String toStatus){
        mappings.remove(new Pair<>(fromStatus, toStatus));
    }

    public static Set<Pair<String,String>> mappings = Sets.newConcurrentHashSet();

}




